package waysing.cream.entity;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.hibernate.annotations.*;
import org.hibernate.annotations.CascadeType;
import javax.persistence.*;
import javax.persistence.Entity;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

/**
 * @author 作者 E-mail:weixinXie 274604559@qq.com
 * @version 创建时间：2018\3\8 0008 19:03
 * @describe 作者很懒，什么都没留下
 */
@Entity
public class Actor {
    @Id
    @GeneratedValue
    private Integer id;
    @Column(name = "name")
    private String name;
    @Column(name = "image")
    private String image;
    @ManyToMany
    @JsonIgnoreProperties(value = {"actors"})
    @Cascade(value = {CascadeType.SAVE_UPDATE, CascadeType.PERSIST})
    @JoinTable(name = "movie_actor",
            joinColumns = {@JoinColumn(name = "actorId", referencedColumnName = "id")},
            inverseJoinColumns = {@JoinColumn(name = "movieId", referencedColumnName = "id")})
    private Set<Movie> movies = new HashSet<>();
    @Column(name = "doubanId")
    private String doubanId;
    @Column(name = "createTime")
    private Date createTime;
    @Column(name = "updateTime")
    private Date updateTime;

    public Actor() {
    }

    public Actor(String name, String image, String doubanId, Date createTime, Date updateTime) {
        this.name = name;
        this.image = image;
        this.doubanId = doubanId;
        this.createTime = createTime;
        this.updateTime = updateTime;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }

    public Set<Movie> getMovies() {
        return movies;
    }

    public void setMovies(Set<Movie> movies) {
        this.movies = movies;
    }

    public String getDoubanId() {
        return doubanId;
    }

    public void setDoubanId(String doubanId) {
        this.doubanId = doubanId;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}
